package com.sugon.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sugon.modules.analyse.consts.DevStatus;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 设备状态历史记录表实体
 * 表名 DEV_STATUS_HISTORY_RECORD
 *
 * @author sugon
 * @date 2020-12-23 11:42:55
 */
@Data
public class DevStatusHistoryRecordEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 持续时长
     */
    private Integer duration;

    /**
     * 结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endDate;

    /**
     * 开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startDate;

    /**
     * 设备状态
     */
    private Integer devstatus;

    /**
     * 设备状态文字描述
     */
    private String devStatusDesc;

    /**
     * 设备ID
     */
    private String devid;
    /**
     * 主键
     */
    private String id;

    public String getDevStatusDesc() {
        String statusDesc = "未知";
        if (devstatus != null) {
            DevStatus devStatus = DevStatus.getInstance(devstatus);
            if (devStatus != null) {
                statusDesc = devStatus.getDesc();
            }
        }
        return statusDesc;
    }

}
